<?php
class xdm
{
	private $tid;
	private $pid;
	private $st;
	private $jid;
	private $cid;
	private $name;
	private $action;
	
	private $pic_url_pre = 'http://www.nonadm.com/comicdata/';
	
	
	
	//定义操作所需要提交的参数
	private $action_vars = array("search"=>"st,name","index"=>"st","getpicurls"=>"tid","cr"=>"tid");
	private $search = array("st"=>0,"name"=>"");
	private $index = array("st"=>0);
	private $getpicurls = array("tid"=>0);
	private $cr = array("tid"=>0);
	
	
	public $DB;
	
	
	private static $Instance = null;
	
	
	
	
	
	//--------------------------------------功能实现部分----------------------------------
	/**
	 * 实现单个采集
	 * 
	 */
	public function fcr(){
		//$tvars = $this->dilivison_vars($this->action);
		//echo $this->action_vars['cr'];
		$tid = $this->tid;
		if(!is_numeric($tid) || $tid < 0){
			show_normal_mesR('TAG ID错误','TAG ID错误','TAG查询');
		}		
		$url = 'http://www.nonadm.com/manhua/' . $tid . '/';
		//分离URL以及ID
		$id = $tid;
		//定义公用变量
		if (substr($url,-1)!="/")
			$url.="/";
		$url_pre = $url;
		$pic_url_pre = $this->pic_url_pre;
		$content = 	file_get_contents($url);
		$content = 	mb_convert_encoding(file_get_contents($url),"UTF-8","GB2312");
		
		
		
		
		
		
	}
	
	
	
	
	
	
	
	
	public function init() {
		
	}
	
	/**
	 * 设置相应操作
	 * @param unknown_type $action
	 */
	public function setAction($action){
		$this->action = $action;
	} 
	/**
	 * 设置分页符
	 * @param unknown_type $st
	 */
	public function setSt($st){
		$this->st = $st;
	}
	/**
	 * 设置搜索操作符
	 * @param unknown_type $name
	 */
	public function setNmae($name){
		$this->name = $name;
	}
	/**
	 * 设置需要采集的ID，用于单采集
	 * @param unknown_type $tid
	 */
	public function setTid($tid){
		$this->tid = $tid;
	}
	
	public function setDB($DB){
		$this->DB = $DB;
	}
	
	
	public static function getInstance() {
		if (self::$Instance === null) {
			$thisClass = __CLASS__;
			self::$Instance = new $thisClass;
			self::init();
		}
		return self::$Instance;
	}
	
	public function __construct(){
		
		
	}
	
	//---------------------------辅助函数部分-----------------------------------------
	/**
	 * 分离动作参数所需要的参数值
	 * 返回值为参数数组
	 * 如果动作错误则返回false
	 * @param $action		动作设置
	 */
	function dilivison_vars($action) {
		if(!is_null($this->action_vars[$action])){
			$vars = explode(',',$this->action_vars[$action]);
			for ($index = 0; $index < count($vars); $index++) {
				$tv[$vars[$index]] = $this->$vars[$index];
			}
			return $tv;
		}
		return false;
	}
	
	
	
	
	
	//---------------------------系统功能部分------------------------------------------
	/**
	 * 图片插入
	 * @param unknown_type $uid
	 * @param unknown_type $url
	 * @param unknown_type $count
	 */
	function do_photoinsert($uid,$url,$count){
		global $DB;
		$DB->do_insert( 'nonadmphotos', array( 
								   'uid'				=> $uid,
								   'url'					=> $url,
								   'count'					=> $count,
								 )		);
		if ($result === false) {
			show_normal_mesR('无法添加当前漫画','添加出错','添加');
		}
	}
	/**
	 * 
	 * @param $id
	 * @param $lu
	 * @param $name
	 * @param $count
	 */
	function do_taginsert($id,$lu,$name,$count){
		global $DB;
		$DB->do_insert( 'nonadmtags', array( 'id'			=> $id,
								   'lastupdate'				=> $lu,
								   'name'					=> $name,
								   'count'					=> $count,
								 )		);
		if ($result === false) {
			show_normal_mesR('无法添加当前漫画','添加出错','添加');
		}
	}
	/**
	 * 系统消息分发器
	 */
	public function mesDivisor(){
		if (method_exists(__CLASS__ ,'f' . $this->action)) {
			$ft = 'f' . $this->action;
			$this->$ft();
		}
	}
	
	
	
	
}

	$ddd = new xdm();
	$ddd->setAction("cr");
	$ddd->setTid(11111);
	$ddd->mesDivisor();




?>